<?

include('../../initDB.php');
include('../../configuration.php');
include('../../querys.php');
include('../../functions.php');
#include('../../output.php');


$error = 0;

if (isset($_REQUEST['user'])) {
	$user = $_REQUEST['user'];
	$user = escape_string($user);
	}
else {
	print_output("error: missing user parameter");
	exit();
}
	
# check for other parameters
# userID query should take place to use in the foreach

$error |= $db_retrieve_tags_user->execute(array($user));
$tags = $db_retrieve_tags_user->fetchAll();

$cleanTags = array();
foreach($tags as $row) {
	$db_retrieve_tags_count->execute(array(':name' => $user, ':tagID' => $row['id'])); 
	$tag_count = $db_retrieve_tags_count->fetch();
	$cleanTags[$row['name']] = $tag_count['total'];
}

#print_r($cleanTags);
print_output($cleanTags);
?>